//无需上 cmd 执行 ffpmeg，执行通过代码控制
const NodeMediaServer = require('node-media-server');
const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 60,
    ping_timeout: 30,
  },
  http: {
    port: 85,
    mediaroot: './media/',
    allow_origin: '*',
  },
  relay: {
    ffmpeg: './ffmpeg.exe',
    tasks: [
      {
        app: 'live',
        mode: 'static',
        edge: 'rtsp://admin:admin123@192.168.5.149:554/Streaming/Channels/301', //rtsp
        name: 'technology',
        rtsp_transport: 'tcp', //['udp', 'tcp', 'udp_multicast', 'http']
      },

      {
        app: 'live',
        mode: 'static',
        edge: 'rtsp://admin:admin123@192.168.5.149:554/Streaming/Channels/401', //rtsp
        name: 'technology1',
        rtsp_transport: 'tcp', //['udp', 'tcp', 'udp_multicast', 'http']
      },

      {
        app: 'live',
        mode: 'static',
        edge: 'rtsp://admin:admin123@192.168.5.149:554/Streaming/Channels/501', //rtsp
        name: 'technology2',
        rtsp_transport: 'tcp', //['udp', 'tcp', 'udp_multicast', 'http']
      },

      {
        app: 'live',
        mode: 'static',
        edge: 'rtsp://admin:admin123@192.168.5.149:554/Streaming/Channels/601', //rtsp
        name: 'technology3',
        rtsp_transport: 'tcp', //['udp', 'tcp', 'udp_multicast', 'http']
      },

      {
        app: 'live',
        mode: 'static',
        edge: 'rtsp://admin:admin123@192.168.5.149:554/Streaming/Channels/701', //rtsp
        name: 'technology4',
        rtsp_transport: 'tcp', //['udp', 'tcp', 'udp_multicast', 'http']
      },
    ],
  },
};

var nms = new NodeMediaServer(config);
nms.run();
